using System;
using UnityEngine;

public class OnTriggerEvent : MonoBehaviour
{
	public delegate void onTriggerEnter(GameObject obj);

	public event onTriggerEnter OnTrigger;

	private void OnTriggerEnter(Collider other)
	{
		UnityEngine.Object.Destroy(this);
	}

	private void OnCollisionEnter(Collision collision)
	{
		UnityEngine.Object.Destroy(this);
	}

	public void InitDestroy(float lifeTime, onTriggerEnter c)
	{
		this.OnTrigger = (onTriggerEnter)Delegate.Combine(this.OnTrigger, c);
		UnityEngine.Object.Destroy(this, lifeTime);
		Invoke("trigger", lifeTime);
	}

	private void trigger()
	{
		this.OnTrigger(base.gameObject);
	}

	public void UnBind(onTriggerEnter c)
	{
		this.OnTrigger = (onTriggerEnter)Delegate.Remove(this.OnTrigger, c);
	}

	private void OnDestroy()
	{
		trigger();
		CancelInvoke();
		this.OnTrigger = null;
	}
}
